package com.eastedu.repository.question.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.eastedu.repository.question.po.QuestionBasicInfoPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author ZHISHUAI.ZHANG
 * @since 2019/2/22
 */
@Mapper
@DS("question")
public interface QuestionBasicInfoMapper extends BaseMapper<QuestionBasicInfoPO> {
    /**
     * 修改知识点
     *
     * @param id        试题ID
     * @param knowledge 知识点
     */
    @Update("UPDATE t_question_basic_info SET knowledge = #{knowledge}, update_time = update_time + 1 WHERE id = #{id}")
    void updateKnowledgeById(@Param("id") Long id, @Param("knowledge") String knowledge);

    /**
     *
     * @param id id
     * @return question name
     */
    @Select("SELECT name FROM t_question_basic_info WHERE id = #{id} LIMIT 1")
    String getQuestionName(@Param("id") Long id);
}
